using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Park.Net.IService;
using Park.Net.IRepository;

namespace Park.Net.Service
{
     public abstract class BaseServices<TEntity> : IBaseServices<TEntity> where TEntity : class, new()
    {
        protected IBaseRepository<TEntity> baseRepository;

        public async Task<bool> CreateAsync(TEntity entity)
        {
            return await baseRepository.CreateAsync(entity);
        }

        public async Task<bool> DeleteAsync(TEntity entity)
        {
            return await baseRepository.DeleteAsync(entity);
        }

        public async Task<List<TEntity>> FindAllAsync()
        {
            return await baseRepository.FindAllAsync();
        }

        public async Task<List<TEntity>> FindManyAsync(Expression<Func<TEntity, bool>> exp)
        {
            return await baseRepository.FindManyAsync(exp);
        }

        public async Task<TEntity> FindOneAsync(int id)
        {
            return await baseRepository.FindOneAsync(id);
        }

        public async Task<TEntity> FindOneAsync(Expression<Func<TEntity, bool>> exp)
        {
            return await FindOneAsync(exp);
        }

        public async Task<bool> UpdateAsync(TEntity entity)
        {
            return await baseRepository.UpdateAsync(entity);
        }
    }
    }
